package com.jic.manager.mapper;

import java.lang.Long;
import java.util.List;

import com.jic.manager.entity.SysUserDept;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 用户数据权限关联表
 *
 * @author :
 * @version : v1.0.0
 * @email :
 * @since : 2020-03-25 01:21:40
 */
@Mapper
public interface SysUserDeptMapper {

    long insert(SysUserDept sysUserDept);

    long foreachInsert(List<SysUserDept> sysUserDepts);

    long delete(Long id);

    long update(SysUserDept sysUserDept);

    SysUserDept queryByPrimaryKey(Long id);

    List<SysUserDept> query(SysUserDept sysUserDept);

    List<SysUserDept> queryPage(@Param("startIndex") int startIndex, @Param("limit") int limit, @Param("sysUserDept") SysUserDept sysUserDept);

    long queryPageCount(SysUserDept sysUserDept);


    List<Long> getUccUserAuthor(@Param("userId") Long userId, @Param("type") Integer type);

    @Delete("delete from sys_user_dept where user_id = #{userId}")
    void deleteByUserId(@Param("userId") Long userId);

    @Select("select business_id from sys_user_dept where user_id = #{userId} and dept_type = #{deptType}")
    List<Long> queryChildByType(@Param("userId") Long userId, @Param("deptType") Integer deptType);

    @Select("select business_id from sys_user_dept where user_id = #{userId}")
    List<Long> queryChildByUserId(@Param("userId") Long userId);
}
